package com.edu.exam.enums.assessment;

/**
 * 考核方式枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum AssessmentMethod {
    WRITTEN_EXAM("WRITTEN_EXAM", "笔试"),
    ORAL_EXAM("ORAL_EXAM", "口试"),
    PRACTICAL("PRACTICAL", "实践操作"),
    HOMEWORK("HOMEWORK", "作业"),
    PROJECT("PROJECT", "项目"),
    PRESENTATION("PRESENTATION", "演讲"),
    PARTICIPATION("PARTICIPATION", "参与度"),
    EXPERIMENT("EXPERIMENT", "实验"),
    REPORT("REPORT", "报告"),
    QUIZ("QUIZ", "测验"),
    OTHER("OTHER", "其他");

    private final String code;
    private final String description;

    AssessmentMethod(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
    /**
     * 根据代码获取枚举值
     *
     * @param code 代码
     * @return 对应的枚举值
     * @throws IllegalArgumentException 如果代码无效
     */
    public static AssessmentMethod fromCode(String code) {
        for (AssessmentMethod method : AssessmentMethod.values()) {
            if (method.code.equals(code)) {
                return method;
            }
        }
        throw new IllegalArgumentException("Unknown assessment method code: " + code);
    }

    /**
     * 根据描述获取枚举值
     *
     * @param description 描述
     * @return 对应的枚举值
     * @throws IllegalArgumentException 如果描述无效
     */
    @Override
    public String toString() {
        return description;
    }
}